package com.fenrirtec.aepp.portal.action;


import java.io.UnsupportedEncodingException;

import javax.servlet.http.HttpServletRequest;

import org.apache.struts2.ServletActionContext;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.fenrirtec.aepp.common.dto.MemberDto;
import com.fenrirtec.aepp.common.service.impl.MemberManageServiceImpl;
import com.fenrirtec.aepp.portal.common.action.CommonAction;

public class PersonalInformationAction extends CommonAction {

	private static final long serialVersionUID = 1L;

	private static final Logger logger = LoggerFactory.getLogger(PersonalInformationAction.class);
    private String memberLoginName;
    private MemberDto memberDto;
    
	public String init() {
		if (logger.isInfoEnabled()) {
			logger.info("[MemberInformationPopupAction#init] start.");
		}
		HttpServletRequest reqeust= ServletActionContext.getRequest();
		memberLoginName = reqeust.getParameter("memberLoginName");
		
		try {
			memberLoginName = new String(memberLoginName.getBytes("iso-8859-1"), "UTF-8");
			if(memberDto == null){
				memberDto=new MemberManageServiceImpl().showMember(memberLoginName);	
				String areaCode=memberDto.getAreaCode();
				String telephone=memberDto.getTelephone();
				if(areaCode != null && telephone != null){
					memberDto.setTel(areaCode+"-"+telephone);
				}	
			}
		} catch (UnsupportedEncodingException e) {			
			e.printStackTrace();
		}
		if (logger.isInfoEnabled()) {
			logger.info("[MemberInformationPopupAction#init] finish.");
		}
		getSession().remove("prePage");
		return SUCCESS;
	}

	public String getMemberLoginName() {
		return memberLoginName;
	}

	public void setMemberLoginName(String memberLoginName) {
		this.memberLoginName = memberLoginName;
	}


	public MemberDto getMemberDto() {
		return memberDto;
	}

	public void setMemberDto(MemberDto memberDto) {
		this.memberDto = memberDto;
	}
    
}
